package com.sunxu.exercise7;

/**
 * ${DESCRIPTION}
 *
 * @author Sun
 * @create 2017-08-02-16:03
 */
public class MyObject {
    private int name;
    public synchronized void methodA() {
        try {
            System.out.println("begin methodA threadName= " + Thread.currentThread().getName());
            Thread.sleep(5000);
            System.out.println("end endTime= " + System.currentTimeMillis());
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    public synchronized void methodB() {
        try {
            System.out.println("begin methodB threadName= " + Thread.currentThread().getName() +
             "begin time=" + System.currentTimeMillis());
            Thread.sleep(5000);
            System.out.println("end");

        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
